package com.cema.manage.project.android.result;

import cn.hutool.json.JSONUtil;

import java.io.Serializable;

public class JsonResult implements Serializable {
    private String msg;
    private int code;
    private Object data;

    public static final int SUCCESS = 0;//数据
    public static final int SUCCESS_2 = 2;//成功提示或
    public static final int SUCCESS_3 = 3;//成功提示或
    public static final int FAIL = 1;//失败提示
    public static final int FAIL_AUTH = -1;//权限
    public static final int RESET_LOGIN = 4;

    public static JsonResult returnSuccess(String requestMsg) {
        JsonResult jsonResult = new JsonResult();
        jsonResult.code = SUCCESS_2;
        jsonResult.msg = requestMsg;
        return jsonResult;
    }

    public static JsonResult returnFail(String requestMsg) {
        JsonResult jsonResult = new JsonResult();
        jsonResult.code = FAIL;
        jsonResult.msg = requestMsg;
        return jsonResult;
    }

    public static JsonResult returnAuth() {
        JsonResult jsonResult = new JsonResult();
        jsonResult.code = FAIL_AUTH;
        return jsonResult;
    }

    public static JsonResult returnAuth(String requestMsg) {
        JsonResult jsonResult = new JsonResult();
        jsonResult.code = FAIL_AUTH;
        jsonResult.msg = requestMsg;
        return jsonResult;
    }
    public static JsonResult returnResult(int requestCode, Object requestData) {
        JsonResult jsonResult = new JsonResult();
        jsonResult.code = requestCode;
        jsonResult.data = JSONUtil.toJsonStr(requestData);
        return jsonResult;
    }

    public static JsonResult returnResetLogin(String requestMsg) {
        JsonResult jsonResult = new JsonResult();
        jsonResult.code = RESET_LOGIN;
        jsonResult.data = requestMsg;
        return jsonResult;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
